-- ==============================================================================================

CREATE OR REPLACE FUNCTION ZOEDEVOPS.ZOEFUN_WERROR_LOG(iv_error_info IN VARCHAR2)
    RETURN VARCHAR2
	
-- Created in 2019.06.18 by polarbears
-- Copyright (c) 20xx, CHINA and/or affiliates.
-- All rights reserved.
--	Name:
-- 		zoefun_werror_log.sql
--	Description:
-- 		
--  Relation:
--      zoeUtility
--	Notes:
--		
--	修改 - （年-月-日） - 描述
--  

AS
PRAGMA AUTONOMOUS_TRANSACTION;
    lv_error_content      VARCHAR2(32767);
    lv_sqlerrm            VARCHAR2(512);
    lv_error_type         VARCHAR2(64);
    lv_error_info         VARCHAR2(4000);
BEGIN
    lv_error_content := json_query(iv_error_info,'$.ERROR_CONTENT') ;
    lv_error_type := json_value(iv_error_info,'$.ERROR_TYPE') ;
    IF lv_error_type IS NULL THEN
        lv_error_type := 'invalid';
    END IF;
    IF lv_error_content IS NULL THEN
        lv_error_content := 'no info';
    END IF;
    lv_error_info := '{"ERROR_TYPE":"'||lv_error_type||'",';
    lv_error_info := lv_error_info||'"ERROR_CONTENT":'||lv_error_content||'}';
    INSERT INTO ZOEDEVOPS.DVP_ERROR_LOG (ERROR_TYPE,ERROR_INFO,ERROR_TIME) VALUES (lv_error_type,lv_error_info,SYSDATE);
    COMMIT;
    RETURN 0;
EXCEPTION 
    WHEN OTHERS THEN
        ROLLBACK;
        lv_sqlerrm := SQLERRM;
        RETURN lv_sqlerrm;
END ZOEFUN_WERROR_LOG;
/

